package com.example.second_home_work

import android.annotation.SuppressLint
import android.os.Bundle
import android.widget.Button
import android.widget.LinearLayout
import android.widget.Spinner
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity

class MainActivity : AppCompatActivity() {
    private val expert = ProgramExpert()
    private var textViewCount = 0

    @SuppressLint("SetTextI18n")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val button: Button = findViewById(R.id.button)
        val spinner: Spinner = findViewById(R.id.spinner)
        val textView: TextView = findViewById(R.id.textView)
        val button2: Button = findViewById(R.id.button2)
        val dynamicLinearLayout: LinearLayout = findViewById(R.id.dynamicLinearLayout)

        button.setOnClickListener {
            val selectedFeature = spinner.selectedItem.toString()
            textView.text = expert.getLanguage(selectedFeature)
        }

        button2.setOnClickListener {
            textViewCount++
            val baseText = getString(R.string.dynamic_text)
            val newTextView = TextView(this).apply {
                text = "$baseText $textViewCount"
            }
            dynamicLinearLayout.addView(newTextView)
        }
    }
}